package thread;

// 测试Thread属性

public class Demo2 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while (true) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"线程线程");
        t.start();

        // Thread的属性
        System.out.println(t.getId()); // java给t安排的身份标识
        System.out.println(t.getName()); // 线程名称
        System.out.println(t.getPriority()); // 优先级
        System.out.println(t.getState()); // 状态
        System.out.println(t.isDaemon()); //是否为后台线程
        System.out.println(t.isAlive()); // 是否存活
        System.out.println(t.isInterrupted());  // 是否被中断
    }
}
